import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Studentvo } from '../vo/studentvo';

@Injectable()
export class StudentService {

  constructor(private http:HttpClient) { }



  private getAnObjectUrl="http://localhost:81/getAnObject";

  getAnObject(){

    return this.http.get(this.getAnObjectUrl).toPromise();

  }

  private addStudentInfoUrl="http://localhost:81/saveStudentInfo";

  addStudentInfo(svo:Studentvo){

    let p={
      "studentid":svo.studentid,
      "xm":svo.xm,
      "xh":svo.xh,
      "sfzh":svo.sfzh
    }

    return this.http.post(this.addStudentInfoUrl,p).toPromise();

  }

  private getStudentListUrl="http://localhost:81/getStudentList";

  getStudentList(){

    return this.http.get(this.getStudentListUrl).toPromise();

  }

  private getSingleStudentUrl="http://localhost:81/getSingleStudentById";

  getSingleStudent(id){
    let p = {
      "studentid":id
    }

    return this.http.post(this.getSingleStudentUrl,p).toPromise();

  }


  private daleteStudentUrl="http://localhost:81/deleteStudent"

  deleteStudent(id:string){
    let p={
      "studentid":id
    }

    return this.http.post(this.daleteStudentUrl,p).toPromise();



  }



}
